#!/usr/bin/env python

"""Convert Hexidecimal to Decimal & vice versa - Christopher D. DeVille"""

import optparse

p = optparse.OptionParser()
p.add_option('-x', '--hex', help="Hexadecimal value to convert to decimal")
p.add_option('-d', '--dec', help="Decimal value to convert to hexadecimal")
(options, args) = p.parse_args()

###Function to convert decimal integer(i) to hex###
def dec2hex(i):
  return "%X" % i

###Function to convert hex string(s) to decimal###
def hex2dec(s):
  return int(s, 16)

hex = options.hex
dec = options.dec

if hex:
  print "hex2dec:", hex2dec(hex)
elif dec:
  print "dec2hex:", dec2hex(int(dec, 10))
else:
  p.print_help() 

